import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class Pandakeylistener implements KeyListener{
	
	Panda pa;
	
	public Pandakeylistener (Panda p){
		pa = p;
	}

	
	@Override
	public void keyPressed(KeyEvent arg0) {
		int 	dx = 0;
		int		dy = 0;
		
		if (arg0.getKeyCode() == KeyEvent.VK_D){
			dx += 1;
		}
		else if (arg0.getKeyCode() == KeyEvent.VK_Q){
			dx -= 1;
		}
		else if (arg0.getKeyCode() == KeyEvent.VK_S){
			dy += 1;
		}
		else if (arg0.getKeyCode() == KeyEvent.VK_Z){
			dy -= 1;
		}
		
		pa.setDirx(dx);
		pa.setDiry(dy);
		
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		pa.setDirx(0);
		pa.setDiry(0);
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
